﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sale.Api.Application.工单.Command.OpenFare;
using Sale.Domain.工单;
using Sale.ErrorCode;

namespace Sale.Api.Controllers
{
    /// <summary>
    /// 开票控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OpenFareController : ControllerBase
    {
        private readonly IMediator mediator;

        public OpenFareController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 开票管理添加接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddOpenFare(AddOpenFareCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 开票管理列表接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<OpenFareModel>> GetOpenFare([FromQuery]GetOpenFareCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 开票管理删除接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<int>> DelOpenFare([FromQuery]DelOpenFareCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<OpenFareModel>>> FanTianOpenFare([FromQuery]FanTianOpenFareCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 开票管理修改接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateOpenFare(UpdateOpenFareCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
